<?php
namespace Tbf\Bundle\AlipayBundle\Model;
use Tbf\Component\Arrays\ArrayFunction;

/**
 * 创建交易请求对象
 * 支持下列支付方式:
 *     即时到帐 cdbu create_direct_pay_by_user
 *     标准双接口 ctbu create_trade_by_user
 */
class CreatePaymentRequest {
    /**
     * 需要用户支付的金额
     * @var  float
     */
    protected $money;
    /**
     * 本站的事务id(可选,缺少会自动生成)
     * @var  string
     */
    protected $trade_id;
    /**
     * 事务api处理回调 应该在此处进行修改数据库状态的事情
     * @var  \Tbf\Bundle\CallbackSerializerBundle\Callback
     *  func(CdbuResponse response)(error)
     */
    protected $api_callback;
    /**
     * 用户返回页面处理回调 应该在此处返回一个response
     * @var  \Tbf\Bundle\CallbackSerializerBundle\Callback
     *  func(CdbuResponse response)(response Response,error)
     */
    protected $page_callback;
    /**
     * 用户可以在某个地方看到的标题(可选,)
     * @var  string
     */
    protected $subject='商品';
    /**
     * 用户可以在某个地方看到的交易内容(可选,)
     * @var  string
     */
    protected $body='商品';
    /**
     * 本站交易的商品url(可选)
     * @var  string
     */
    protected $good_url='';
    /**
     * 附加数据(可选,保存在本地数据库,不会发给支付宝..)(可以保存一个数组,json_encode)
     * @var string
     */
    protected $extra_data;
    /**
     * 收货人姓名,(可选)
     * 标准双接口
     *   至少需要传入  receive_name,receive_address,receive_zip  保存进度
     *   如果不传入则会要求用户在支付宝输入地址,
     * 即时到帐 该参数被忽略
     * @var string
     */
    protected $receive_name;
    /**
     * 收货人地址,(可选,其他同 收货人姓名)
     * @var string
     */
    protected $receive_address;
    /**
     * 收货人邮编,(可选,其他同 收货人姓名)
     * @var string
     */
    protected $receive_zip;
    /**
     * 收货人电话,(可选,其他同 收货人姓名)
     * @var string
     */
    protected $receive_phone;
    /**
     * 收货人手机,(可选,其他同 收货人姓名)
     * @var string
     */
    protected $receive_mobile;
    function __construct($input){
        $err = ArrayFunction::checkParameterExist($input,
            array('money','api_callback','page_callback'));
        if ($err!==null){
            throw new \Exception($err);
        }
        if (!empty($input['trade_id'])){
            $this->trade_id = $input['trade_id'];
        }
        $this->money = $input['money'];
        $this->api_callback = $input['api_callback'];
        $this->page_callback = $input['page_callback'];
    }
    /**
     * @param \Tbf\Bundle\CallbackSerializerBundle\CallbackInterface $api_callback
     */
    public function setApiCallback($api_callback)
    {
        $this->api_callback = $api_callback;
    }

    /**
     * @return \Tbf\Bundle\CallbackSerializerBundle\CallbackInterface
     */
    public function getApiCallback()
    {
        return $this->api_callback;
    }

    /**
     * @param string $body
     */
    public function setBody($body)
    {
        $this->body = $body;
    }

    /**
     * @return string
     */
    public function getBody()
    {
        return $this->body;
    }

    /**
     * @param string $good_url
     */
    public function setGoodUrl($good_url)
    {
        $this->good_url = $good_url;
    }

    /**
     * @return string
     */
    public function getGoodUrl()
    {
        return $this->good_url;
    }

    /**
     * @param float $money
     */
    public function setMoney($money)
    {
        $this->money = $money;
    }

    /**
     * @return float
     */
    public function getMoney()
    {
        return $this->money;
    }

    /**
     * @param \Tbf\Bundle\CallbackSerializerBundle\CallbackInterface $page_callback
     */
    public function setPageCallback($page_callback)
    {
        $this->page_callback = $page_callback;
    }

    /**
     * @return \Tbf\Bundle\CallbackSerializerBundle\CallbackInterface
     */
    public function getPageCallback()
    {
        return $this->page_callback;
    }

    /**
     * @param string $subject
     */
    public function setSubject($subject)
    {
        $this->subject = $subject;
    }

    /**
     * @return string
     */
    public function getSubject()
    {
        return $this->subject;
    }

    /**
     * @param string $trade_id
     */
    public function setTradeId($trade_id)
    {
        $this->trade_id = $trade_id;
    }

    /**
     * @return string
     */
    public function getTradeId()
    {
        return $this->trade_id;
    }

    /**
     * @param string $extra_data
     */
    public function setExtraData($extra_data)
    {
        $this->extra_data = $extra_data;
    }

    /**
     * @return string
     */
    public function getExtraData()
    {
        return $this->extra_data;
    }

    /**
     * @param string $receive_address
     */
    public function setReceiveAddress($receive_address)
    {
        $this->receive_address = $receive_address;
    }

    /**
     * @return string
     */
    public function getReceiveAddress()
    {
        return $this->receive_address;
    }

    /**
     * @param string $receive_mobile
     */
    public function setReceiveMobile($receive_mobile)
    {
        $this->receive_mobile = $receive_mobile;
    }

    /**
     * @return string
     */
    public function getReceiveMobile()
    {
        return $this->receive_mobile;
    }

    /**
     * @param string $receive_name
     */
    public function setReceiveName($receive_name)
    {
        $this->receive_name = $receive_name;
    }

    /**
     * @return string
     */
    public function getReceiveName()
    {
        return $this->receive_name;
    }

    /**
     * @param string $receive_phone
     */
    public function setReceivePhone($receive_phone)
    {
        $this->receive_phone = $receive_phone;
    }

    /**
     * @return string
     */
    public function getReceivePhone()
    {
        return $this->receive_phone;
    }

    /**
     * @param string $receive_zip
     */
    public function setReceiveZip($receive_zip)
    {
        $this->receive_zip = $receive_zip;
    }

    /**
     * @return string
     */
    public function getReceiveZip()
    {
        return $this->receive_zip;
    }

}